package com.yx.front.controller;


import com.yx.front.annotation.AnonymousAccess;
import com.yx.front.config.global.CommonResult;
import com.yx.front.manager.BookMessageManager;
import com.yx.front.model.param.BookMessageParam;
import com.yx.front.model.vo.BookMessageVo;
import com.yx.front.model.vo.KindTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 图书信息表 前端控制器
 * </p>
 *
 * @author YangXiong
 * @since 2023-03-29
 */
@Slf4j
@Api(tags = "书本信息接口")
@RestController
@RequestMapping("/book-message")
public class BookMessageController {
    @Resource
    private BookMessageManager bookMessageManager;

    @PostMapping("/page")
    @AnonymousAccess
    @ApiOperation("书本信息分页查询")
    public CommonResult<List<BookMessageVo>> getBookMessageList(@RequestBody BookMessageParam param) {
        log.info("BookMessageController getBookMessageList info BookMessageParam={}", param);
        return bookMessageManager.getBookMessageList(param);
    }

    @PostMapping("/detail")
    @AnonymousAccess
    @ApiOperation("根据id查询书本详情")
    public CommonResult<BookMessageVo> getDetail(@RequestBody BookMessageParam param) {
        log.info("BookMessageController getDetail info BookMessageParam={}", param);
        BookMessageVo result = bookMessageManager.getDetail(param.getId());
        return CommonResult.success(result);
    }

    @GetMapping("/kind/list")
    @AnonymousAccess
    @ApiOperation("查询分类列表")
    public CommonResult<KindTypeVo> getTypeAndKind(){
        return bookMessageManager.getTypeAndKind();
    }

    @GetMapping("/advice")
    @AnonymousAccess
    @ApiOperation("小编推荐列表")
    public CommonResult<List<BookMessageVo>> adviceList(){
        return bookMessageManager.adviceList();
    }
}

